package com.yljk.homedoctor.viewmodel;



import android.Manifest;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.provider.MediaStore;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.text.style.TextAppearanceSpan;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.LifecycleOwner;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.arialyy.aria.util.ALog;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.google.android.material.tabs.TabLayout;
import com.yilijk.base.base.BaseViewModel;
import com.yilijk.base.constants.UserInfo;
import com.yilijk.base.network.https.HttpCallBack;
import com.yilijk.base.network.https.HttpUtils;
import com.yilijk.base.utils.BitmapUtils;
import com.yilijk.base.utils.ClickUtils;
import com.yilijk.base.utils.CommonUtils;
import com.yilijk.base.utils.DataUtils;
import com.yilijk.base.utils.DevicesUtils;
import com.yilijk.base.utils.LoadingUtils;
import com.yilijk.base.utils.SharedPreferencesUtils;
import com.yilijk.base.utils.UIUtils;
import com.yljk.homedoctor.HomeUtils;
import com.yljk.homedoctor.R;
import com.yljk.homedoctor.adapter.CommonAdapter;
import com.yljk.homedoctor.adapter.DoctorGuideAdapter;
import com.yljk.homedoctor.adapter.LiveAdapter;
import com.yljk.homedoctor.adapter.MyRoomAdapter;
import com.yljk.homedoctor.databinding.HomeFragmentDataBinding;
import com.yljk.homedoctor.model.entity.ConsultingReminBean;
import com.yljk.homedoctor.model.entity.DoctorTirmEntity;
import com.yljk.homedoctor.model.entity.DrugShareEntity;
import com.yljk.homedoctor.model.entity.HomeDoctorDetailEntity;
import com.yljk.homedoctor.model.entity.LiveListEntity;
import com.yljk.homedoctor.model.entity.MyRoonEntity;
import com.yljk.homedoctor.model.entity.ScanEntity;
import com.yljk.homedoctor.model.entity.live.LiveTabBean;
import com.yljk.homedoctor.model.HomeModel;
import com.yljk.homedoctor.view.dialog.HealthDialog;
import com.yljk.homedoctor.viewmodel.listener.PopWindowListenter;
import com.yljk.homedoctor.view.view.ProtocalDialog;
import com.yljk.live.common.utils.MediaCountyManager;
import com.yljk.live.home.bean.cms.AlbumBean;
import com.yljk.servicemanager.bean.ProtocalEntity;
import com.yljk.servicemanager.constants.ClickApi;
import com.yljk.servicemanager.constants.ConfigApi;
import com.yljk.servicemanager.constants.LocalUserInfo;
import com.yljk.servicemanager.constants.ReactApi;
import com.yljk.servicemanager.constants.RouterApi;
import com.yljk.servicemanager.interfaceapi.HomeBackApi;
import com.yljk.servicemanager.interfaceapi.MineBackApi;
import com.youth.banner.loader.ImageLoader;
import com.youth.banner2.util.LogUtils;
import com.zzhoujay.richtext.RichText;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by SHICHENG
 * <p>
 * Time on
 */
public class HomeViewModel extends BaseViewModel<HomeModel> {
    private Handler handler = new Handler();
    private String[] urls = new String[]{
            "yszcxy", "flsmjyszc", "ysdjgbalwxy"
    };
    private String[] titles = new String[]{
            "《慧医天下医生注册协议》", "《法律声明及隐私权政策》", "《医师多机构备案劳务协议》"
    };
    //我的诊室 功能ID
    private final int MY_INQURIY_ID = 1001;
    private final int MY_PRESCRIPTION_ID = 1002;
    private final int MY_PATIENTS_ID = 1003;
    private final int MY_SCAN_ID = 1004;
    private final int MY_FOLLOWUP_ID = 1005;
    private final int MY_LIVE_ID = 1006;
    private final int MY_MEET_ID = 1007;
    private final int MY_STUDIO_ID = 1008;
    private ArrayList<MyRoonEntity> myRoomEntities;
    public MyRoomAdapter myRoomAdapter;
    private final float topScrollYFloat = 200.0f;
    //==============================注册协议弹窗
    private ProtocalDialog.Builder protocalDialogBuilder;
    private ProtocalDialog protocalDialog;
    //===================常用套餐
    public CommonAdapter commonAdapter;
    private ArrayList<HomeDoctorDetailEntity.DataBean.DoctorPacketSetsListBean> commonEntities;
    //=========================轮播图
    private ArrayList<String> banners;
    private ArrayList<String> bannersUrl;
    private List<Object> bannerList;
    //===========================医生指南
    private ArrayList<HomeDoctorDetailEntity.DataBean.DocumentListBean.ListBean> doctorGuides;
    public DoctorGuideAdapter doctorGuideAdapter;
    //===================
    public LiveAdapter liveAdapter;
    private ArrayList<LiveListEntity.DataBean.ListBean> lives;
    //公告数据
    private ArrayList<HomeDoctorDetailEntity.DataBean.NoticeListBean> noticeListBeans = new ArrayList<>();
    private ArrayList<String> notices = new ArrayList<>();
    //医生详情
    private HomeDoctorDetailEntity.DataBean doctorDetailInfo;
    //本地弹窗状态
    private int localPreliminaryStatus;
    private int localPracticeStatus;
    private boolean isFirstAzUseNew;

    HomeFragmentDataBinding binding;
    Context context;
    PopWindowListenter popWindowListenter;
    private LiveTabBean.DataBean.MeetingBean meetingContentBean;
    List<LiveTabBean.DataBean.LiveCategoryBean> live_category;
    public HomeViewModel(@NonNull Application application) {
        super(application);
    }

    public void setBinding(Context context, HomeFragmentDataBinding binding, PopWindowListenter popWindowListenter) {
        this.context = context;
        this.binding = binding;
        this.popWindowListenter = popWindowListenter;
    }

    public void initDailogAndPop() {
        //注册协议初始化
        initProtocalDialog();
    }

    /**
     * 注册协议初始化
     */
    void initProtocalDialog() {
        protocalDialogBuilder = new ProtocalDialog.Builder(context);

//        protocalDialogBuilder.setMessage();

        protocalDialogBuilder.setPositiveButton("同意", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                LoadingUtils.getLoadingUtils(context).showLoading();
                getRepository().getPreserveAgreeBt(new HttpCallBack<String>() {
                    @Override
                    public void onSuccess(String s, int i) {
                        LoadingUtils.getLoadingUtils(context).dismissLoading();
                        try {
                            JSONObject jsonObject1 = new JSONObject(s);
                            boolean data = jsonObject1.getBoolean("data");
                            if (data) {
                                protocalDialog.dismiss();
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }

                    @Override
                    public void onFailure(String s, int i) {
                        LoadingUtils.getLoadingUtils(context).dismissLoading();
                    }
                });
            }
        });
        protocalDialogBuilder.setNegativeButton("不同意", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                //不同意推出登录
                MineBackApi mineBackApi = (MineBackApi) ARouter.getInstance().build(RouterApi.MINEBACKIMPL).navigation();
                mineBackApi.onCancelLogout((Activity) context, context);
            }
        });
    }

    public void getHealthData(){
        getRepository().getHealthData(new HttpCallBack<ConsultingReminBean>() {
            @Override
            public void onSuccess(ConsultingReminBean s, int code) {
                if (s.isResult()){
                    if (s.getData().isRemind()){
                        showHealthDialog();
                    }
                }
            }

            @Override
            public void onFailure(String s, int i) {

            }
        });
    }
    void showHealthDialog(){
        HealthDialog healthDialog = new HealthDialog(context);
        healthDialog.show();
    }

    /**
     * 检查是否需要弹窗
     */
    public void checkPreserveAgreement() {
        getRepository().getCheckPreserveAgreement(new HttpCallBack<String>() {
            @Override
            public void onSuccess(String s, int i) {
                try {
                    JSONObject jsonObject1 = new JSONObject(s);
                    boolean result = jsonObject1.getBoolean("result");
                    if (result) {
                        boolean data = jsonObject1.getBoolean("data");
                        if (data) {
                            getRegistText();
                        }
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFailure(String s, int i) {

            }
        });
    }

    /**
     * 获取注册协议文案
     */
    void getRegistText() {
        if (protocalDialog != null && protocalDialog.isShowing()){
            return;
        }
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("documentNo", "authAgree");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        final SpannableStringBuilder style = new SpannableStringBuilder();

        final String content = "感谢您对慧医天下互联网医疗平台的信任！为了更好地保护您的个人信息安全和合法权益，请您务必仔细阅读并充分理解我们最新的《慧医天下医生注册协议》、《法律声明及隐私权政策》和《医师多机构备案劳务协议》。我们将严格按照您同意的各项条款使用和保护您的个人信息，并为您提供相关服务。\n" +
                "详细信息请阅读完整版《慧医天下医生注册协议》、《法律声明及隐私权政策》和《医师多机构备案劳务协议》。";

        //设置文字
        style.append(content);


        int a_l = content.indexOf("《慧医天下医生注册协议》");
        int a_L = a_l + "《慧医天下医生注册协议》".length();

        int a_l2 = content.lastIndexOf("《慧医天下医生注册协议》");
        int a_L2 = a_l2 + "《慧医天下医生注册协议》".length();


        int b_l = content.indexOf("《法律声明及隐私权政策》");
        int b_L = b_l + "《法律声明及隐私权政策》".length();

        int b_l2 = content.lastIndexOf("《法律声明及隐私权政策》");
        int b_L2 = b_l2 + "《法律声明及隐私权政策》".length();

        int c_l = content.indexOf("《医师多机构备案劳务协议》");
        int c_L = c_l + "《医师多机构备案劳务协议》".length();

        int c_l2 = content.lastIndexOf("《医师多机构备案劳务协议》");
        int c_L2 = c_l2 + "《医师多机构备案劳务协议》".length();

        style.setSpan(new ClickableSpan() {
            @Override
            public void onClick(@NonNull View widget) {
                toWebAgreement(1);
            }
        }, a_l, a_L, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        style.setSpan(new ClickableSpan() {
            @Override
            public void onClick(@NonNull View widget) {
                toWebAgreement(1);
            }
        }, a_l2, a_L2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        style.setSpan(new ClickableSpan() {
            @Override
            public void onClick(@NonNull View widget) {
                toWebAgreement(2);
            }
        }, b_l, b_L, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        style.setSpan(new ClickableSpan() {
            @Override
            public void onClick(@NonNull View widget) {
                toWebAgreement(2);
            }
        }, b_l2, b_L2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        style.setSpan(new ClickableSpan() {
            @Override
            public void onClick(@NonNull View widget) {
                toWebAgreement(3);
            }
        }, c_l2, c_L2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        style.setSpan(new ClickableSpan() {
            @Override
            public void onClick(@NonNull View widget) {
                toWebAgreement(3);
            }
        }, c_l, c_L, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        style.setSpan(new StyleSpan(Typeface.BOLD), a_l, a_L, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        style.setSpan(new StyleSpan(Typeface.BOLD), a_l2, a_L2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        style.setSpan(new StyleSpan(Typeface.BOLD), b_l, b_L, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        style.setSpan(new StyleSpan(Typeface.BOLD), b_l2, b_L2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        style.setSpan(new StyleSpan(Typeface.BOLD), c_l, c_L, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        style.setSpan(new StyleSpan(Typeface.BOLD), c_l2, c_L2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        //设置部分文字颜色
        style.setSpan(new ForegroundColorSpan(Color.parseColor("#1A1A1A")), a_l, a_L, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        style.setSpan(new ForegroundColorSpan(Color.parseColor("#1A1A1A")), a_l2, a_L2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        style.setSpan(new ForegroundColorSpan(Color.parseColor("#1A1A1A")), b_l, b_L, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        style.setSpan(new ForegroundColorSpan(Color.parseColor("#1A1A1A")), b_l2, b_L2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        style.setSpan(new ForegroundColorSpan(Color.parseColor("#1A1A1A")), c_l, c_L, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        style.setSpan(new ForegroundColorSpan(Color.parseColor("#1A1A1A")), c_l2, c_L2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        protocalDialogBuilder.setMessage(style);


        if (protocalDialog != null && protocalDialog.isShowing()){
            protocalDialog.dismiss();
        }
        protocalDialog = protocalDialogBuilder.create();
        protocalDialog.setCancelable(false);
        protocalDialog.show();
//        NetWorkUtils.get(DevicesUtils.getUrl() + AllStringConstants.getByDocumentNo, jsonObject, new NetWorkCallBack() {
//            @Override
//            public void onSuccess(String resultMsg, int code) {
//                if (code == 200) {
//                    ProtocalEntity protocalEntity = new Gson().fromJson(resultMsg, ProtocalEntity.class);
//                    if (protocalEntity.getStatus().equals("200")) {
//                        protocalDialog = protocalDialogBuilder.create();
//                        protocalDialog.setCancelable(false);
//                        protocalDialog.show();
//                    }
//                }
//            }
//
//            @Override
//            public void onFailure(String failureMsg) {
//
//            }
//
//            @Override
//            public void onException(Exception exceptionMsg, int code) {
//
//            }
//        });
    }

    /**
     * 跳转WebView展示协议文案
     */
    void toWebAgreement(int i) {
        String url = (DevicesUtils.isEnvironment() ? "https://www.d1.yilijk.com" : "https://www.yilijk.com") + "/document/index.html?id=" + urls[i - 1];
        ALog.i("toWebAgreement", "toWebAgreement: " + url);
        ARouter.getInstance().build("/WebActivity/WebActivity")
                .withString("title", titles[i - 1])
                .withString("url", url)
                .withBoolean("ishtml", false)
                .navigation();
    }

    /**
     * view初始化
     */
    public void initView() {
        initMyRoom();
        initCommon();
        initBanner();
        initDoctorGuide();
        initLive();
        binding.notice.setNoticeList(notices);
        if (context != null) {
            RichText.initCacheDir(context);
        }
        binding.notice.start();
    }

    /**
     * 我的诊室
     */
    void initMyRoom() {
        myRoomEntities = new ArrayList<>();
        myRoomAdapter = new MyRoomAdapter(myRoomEntities);
        binding.myRoom.setLayoutManager(new GridLayoutManager(context, 4));
        binding.myRoom.setAdapter(myRoomAdapter);
        myRoomAdapter.notifyDataSetChanged();
        //直播
        //我的问诊
        myRoomEntities.add(new MyRoonEntity(MY_INQURIY_ID, "我的问诊",
                CommonUtils.imageTranslateUri(context, R.mipmap.my_inquriy),
                CommonUtils.imageTranslateUri(context, R.mipmap.my_inquriy_no),
                0,
                false));
        //我的处方
        myRoomEntities.add(new MyRoonEntity(MY_PRESCRIPTION_ID, "我的处方",
                CommonUtils.imageTranslateUri(context, R.mipmap.my_prescription),
                CommonUtils.imageTranslateUri(context, R.mipmap.my_prescription_no),
                0,
                false));
        //我的患教
        myRoomEntities.add(new MyRoonEntity(MY_PATIENTS_ID, "我的患教",
                CommonUtils.imageTranslateUri(context, R.mipmap.my_patients),
                CommonUtils.imageTranslateUri(context, R.mipmap.my_patients_no),
                0,
                false));
        //出示二维码
        myRoomEntities.add(new MyRoonEntity(MY_SCAN_ID, "出示二维码",
                CommonUtils.imageTranslateUri(context, R.mipmap.showqrcode),
                CommonUtils.imageTranslateUri(context, R.mipmap.showqrcode_no),
                0,
                false));
        //我的随访
        myRoomEntities.add(new MyRoonEntity(MY_FOLLOWUP_ID, "患者随访",
                CommonUtils.imageTranslateUri(context, R.mipmap.followup),
                CommonUtils.imageTranslateUri(context, R.mipmap.unfollowup),
                0,
                false));
        notifityLiveAdapter();
    }

    /**
     * 常用套餐
     */
    void initCommon() {
        commonEntities = new ArrayList<>();
        commonAdapter = new CommonAdapter(commonEntities);
        binding.commonRecycler.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
        binding.commonRecycler.setAdapter(commonAdapter);
        commonAdapter.notifyDataSetChanged();
    }

    /**
     * banner轮播图
     */
    void initBanner() {
        banners = new ArrayList<>();
        bannersUrl = new ArrayList<>();
        bannerList = new ArrayList<>();
        binding.homeBanner.setImages(banners);
        binding.homeBanner.setImageLoader(new ImageLoader() {
            @Override
            public void displayImage(Context context, Object path, ImageView imageView) {
                try {
                    Glide.with(context).load(path).into(imageView);
                } catch (Throwable throwable) {

                }
            }
        });
        binding.homeBanner.start();
    }

    /**
     * 医生指南
     */
    void initDoctorGuide() {
        doctorGuides = new ArrayList<>();
        doctorGuideAdapter = new DoctorGuideAdapter(doctorGuides);
        binding.doctorGuideRecycler.setLayoutManager(new LinearLayoutManager(context));
        binding.doctorGuideRecycler.setAdapter(doctorGuideAdapter);
        doctorGuideAdapter.notifyDataSetChanged();
    }

    /**
     * 直播列表
     */
    void initLive() {
        lives = new ArrayList<>();
        liveAdapter = new LiveAdapter(lives);
        binding.liveRecycler.setLayoutManager(new LinearLayoutManager(context, RecyclerView.HORIZONTAL, false));
        binding.liveRecycler.setAdapter(liveAdapter);
        liveAdapter.notifyDataSetChanged();
    }


    @Override
    public void createRepository() {
        super.createRepository();
        repository = new HomeModel();
    }

    @Override
    protected void onCleared() {
        super.onCleared();
    }

    public void getData() {
        getRepository().getDoctorDetail(new HttpCallBack<HomeDoctorDetailEntity>() {
            @Override
            public void onSuccess(HomeDoctorDetailEntity homeDoctorDetailEntity, int code) {
                if (homeDoctorDetailEntity.isResult()) {
                    if (homeDoctorDetailEntity.getData() == null) {
                        LogUtils.e("homeDoctorDetailEntity Data is null");
                        return;
                    }
                    HomeDoctorDetailEntity.DataBean data = homeDoctorDetailEntity.getData();
                    //存储本地数据
                    SharedPreferencesUtils.getInstance().save(LocalUserInfo.hospitalName,data.getHospitalName());
                    SharedPreferencesUtils.getInstance().save(UserInfo.imgUrl,data.getAvatar());
                    SharedPreferencesUtils.getInstance().save(UserInfo.JobtitleDesc,data.getTitleName());
                    SharedPreferencesUtils.getInstance().save(UserInfo.preliminartStatus,data.getPreliminaryStatus());
                    SharedPreferencesUtils.getInstance().save(UserInfo.practiceStatus,data.getPracticeStatus());
                    SharedPreferencesUtils.getInstance().save(UserInfo.userName,data.getName());

                    //更新腾讯IM用户信息
                    MediaCountyManager.getInstance().updateSelfProfile();

                    binding.guideDoctorTxt.setText(data.getTitle()&&data.getPreliminaryStatus()==2 ?
                                    "当前职称不可开通问诊服务，升级主治医师及以上职称即可开启！":
                                    "已有"+data.getTryInquiryPatientCount()+"位患者提交了问诊意向， 是否开通问诊服务?");
                    binding.guideDoctorBt.setText(data.getTitle() && data.getPreliminaryStatus() == 2?
                                        "升级职称":"开通问诊");
                    binding.bzAvatarIv.setVisibility(data.isBzShow()?View.VISIBLE:View.GONE);
                    binding.isSelfSupportLayout.setVisibility(data.isBzShow() ? View.VISIBLE : View.GONE);
                    if (data.getTitle() && data.getPreliminaryStatus() == 2) {
                        //问诊升级
                        binding.guideDoctorToOpen.setVisibility(View.VISIBLE);
                        //已有5位患者提交了问诊意向， 是否开通问
                        binding.guideDoctorTxt.setText("当前职称不可开通问诊服务，升级主治医师及以上职称即可开启！");
                        binding.guideDoctorBt.setText("升级职称");
                    } else if (ConfigApi.Open.GuideOpenAndUp && data.getTryInquiryPatientCount() > 0) {
                        //问诊开通
                        findViewById(R.id.guide_doctor_to_open).setVisibility(View.VISIBLE);
                        //已有5位患者提交了问诊意向， 是否开通问
//                            String guide_doctor_txt = "已有"+doctorDetail.getData().getTryInquiryPatientCount()+"位患者提交了问诊意向， 是否开通问";
                        ColorStateList redColors = ColorStateList.valueOf(((Activity)context).getResources().getColor(R.color.color_FF5533));
                        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder("已有" + data.getTryInquiryPatientCount() + "位患者提交了问诊意向， 是否开通问诊服务?");
                        spannableStringBuilder.setSpan(new TextAppearanceSpan(null, Typeface.BOLD, UIUtils.dp2px(context, 18), redColors, null), 2, 3, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
                        ((TextView) (findViewById(R.id.guide_doctor_txt))).setText(spannableStringBuilder);
                        ((TextView) (findViewById(R.id.guide_doctor_bt))).setText("开通问诊");
                    } else {
                        findViewById(R.id.guide_doctor_to_open).setVisibility(View.GONE);
                    }
                    binding.bgTop.setBackgroundResource(data.isBzShow() ? R.mipmap.nav_bg_super : R.mipmap.nav_bg);
                    binding.homeName.setTextColor(data.isBzShow() ? context.getResources().getColor(R.color.bz_earth_color) : context.getResources().getColor(R.color.white));
                    binding.homeTitleName.setTextColor(data.isBzShow() ? context.getResources().getColor(R.color.bz_earth_color) : context.getResources().getColor(R.color.white));
                    binding.homeServerPatiensTitle.setTextColor(data.isBzShow() ? context.getResources().getColor(R.color.bz_earth_color) : context.getResources().getColor(R.color.white));
                    binding.homeServerPatiens.setTextColor(data.isBzShow() ? context.getResources().getColor(R.color.bz_earth_color) : context.getResources().getColor(R.color.white));
                    binding.homeInqurityCountTitle.setTextColor(data.isBzShow() ? context.getResources().getColor(R.color.bz_earth_color) : context.getResources().getColor(R.color.white));
                    binding.homeInqurityCount.setTextColor(data.isBzShow() ? context.getResources().getColor(R.color.bz_earth_color) : context.getResources().getColor(R.color.white));
                    binding.homePatientCount.setTextColor(data.isBzShow() ? context.getResources().getColor(R.color.bz_earth_color) : context.getResources().getColor(R.color.white));
                    binding.homePatientCountTitle.setTextColor(data.isBzShow() ? context.getResources().getColor(R.color.bz_earth_color) : context.getResources().getColor(R.color.white));
                    binding.homeTitleTop.setBackgroundResource(data.isBzShow() ? R.color.white : R.mipmap.toolbar_bg);
                    binding.titleName.setTextColor(data.isBzShow() ? context.getResources().getColor(R.color.color_333333) : context.getResources().getColor(R.color.white));
                    float v = binding.homeNestedScrollView.getScrollY() / topScrollYFloat > 1 / 0f ? 1.0f : binding.homeNestedScrollView.getScrollY() / topScrollYFloat;
                    binding.homeTitleTop.setAlpha(data.isBzShow() ? v : 1.0f);

                    //更新公告
                    if (data.getNoticeList() != null) {
                        notices.clear();
                        noticeListBeans.clear();
                        for (int i = 0; i < data.getNoticeList().size(); i++) {
                            notices.add(data.getNoticeList().get(i).getTitle());
                            noticeListBeans.add(data.getNoticeList().get(i));
                        }
                    }

                    //轮播图
                    bannerList.clear();
                    if (data.getBannerList() != null) {
                        bannerList.addAll(data.getBannerList());
                        banners.clear();
                        bannersUrl.clear();
                        for (int i = 0; i < data.getBannerList().size(); i++) {
                            banners.add(data.getBannerList().get(i).getImageUrl());
                            bannersUrl.add(data.getBannerList().get(i).getUrl());
                        }
                    }
                    if (data.getActivityResultList() != null) {
                        bannerList.addAll(data.getActivityResultList());
                        for (int i = 0; i < data.getActivityResultList().size(); i++) {
                            banners.add(data.getActivityResultList().get(i).getBannerImage());
                            bannersUrl.add(data.getActivityResultList().get(i).getUrl());
                        }
                    }

                    //请求IM账号
                    if (data.getPreliminaryStatus() == 2 || data.getPracticeStatus() == 2) {
//                            getImAccount();
                        String imAccount = SharedPreferencesUtils.getInstance().getString(UserInfo.imAccount, "");
                        String imPassword = SharedPreferencesUtils.getInstance().getString(UserInfo.imPassword, "");
                        if (TextUtils.isEmpty(imAccount) || TextUtils.isEmpty(imPassword)) {
                            return;
                        }
                        HomeBackApi homeBackApi = (HomeBackApi) ARouter.getInstance().build(RouterApi.HOMEONCLICKIMPL).navigation();
                        homeBackApi.imAccount((Activity) context,
                                imAccount,
                                imPassword);
                    }
                    if (data.isShowDoctorConfirm()) {
//                            doctorConfirm();
                    }

                    if (data.getAgreement() == 0) {
                        //个税通知弹窗
                    }
//                    //更新公告
//                    if (data.getNoticeList() != null) {
//                        notices.clear();
//                        noticeListBeans.clear();
//                        for (int i = 0; i < data.getNoticeList().size(); i++) {
//                            notices.add(data.getNoticeList().get(i).getTitle());
//                            noticeListBeans.add(data.getNoticeList().get(i));
//                        }
//                    }
//                    //轮播图
//                    bannerList.clear();
//                    if (data.getBannerList() != null) {
//                        bannerList.addAll(data.getBannerList());
//                        banners.clear();
//                        bannersUrl.clear();
//                        for (int i = 0; i < data.getBannerList().size(); i++) {
//                            banners.add(data.getBannerList().get(i).getImageUrl());
//                            bannersUrl.add(data.getBannerList().get(i).getUrl());
//                        }
//                    }
                    if (data.getActivityResultList() != null) {
                        bannerList.addAll(data.getActivityResultList());
                        for (int i = 0; i < data.getActivityResultList().size(); i++) {
                            banners.add(data.getActivityResultList().get(i).getBannerImage());
                            bannersUrl.add(data.getActivityResultList().get(i).getUrl());
                        }
                    }
                    //请求IM账号
                    if (data.getPreliminaryStatus() == 2 || data.getPracticeStatus() == 2) {
                        String imAccount = SharedPreferencesUtils.getInstance().getString(UserInfo.imAccount, "");
                        String imPassword = SharedPreferencesUtils.getInstance().getString(UserInfo.imPassword, "");
                        if (TextUtils.isEmpty(imAccount) || TextUtils.isEmpty(imPassword)) {
                            return;
                        }
                        HomeBackApi homeBackApi = (HomeBackApi) ARouter.getInstance().build(RouterApi.HOMEONCLICKIMPL).navigation();
                        homeBackApi.imAccount((Activity) context,
                                imAccount,
                                imPassword);
                    }
                    if (data.isShowDoctorConfirm()) {
                        getDoctorConfitm();
                    }
                    doctorDetailInfo = data;
                    LoadingUtils.getLoadingUtils(context).dismissLoading();
                    // 个税通知弹窗
                    if (doctorDetailInfo.getAgreement() == 0) {
                        popWindowListenter.individual();
                    }
                    if (!doctorDetailInfo.isPrescriptionSupport()) {
                        binding.isSelfSupportLayout.setVisibility(View.VISIBLE);
                    } else {
                        binding.isSelfSupportLayout.setVisibility(View.GONE);
                    }

                    //医生指南
                    if (doctorDetailInfo.getDocumentList() != null && doctorDetailInfo.getDocumentList().getList().size() > 0) {
                        findViewById(R.id.doctorGuideCardView).setVisibility(View.VISIBLE);
                        doctorGuides.clear();
                        doctorGuides.addAll(doctorDetailInfo.getDocumentList().getList());
                        doctorGuideAdapter.notifyDataSetChanged();
                    } else {
                        findViewById(R.id.doctorGuideCardView).setVisibility(View.GONE);
                    }
                    //常用套餐
                    if (doctorDetailInfo.getDoctorPacketSetsList() != null && doctorDetailInfo.getDoctorPacketSetsList().size() > 0) {
                        binding.commonPacketCardview.setVisibility(View.VISIBLE);
                        commonEntities.clear();
                        commonEntities.addAll(doctorDetailInfo.getDoctorPacketSetsList());
                        commonAdapter.notifyDataSetChanged();
                    } else {
                        binding.commonPacketCardview.setVisibility(View.GONE);
                    }
                    //医网签设置
//                if (doctorDetailInfo.getEnvType() != null) {
//                    HomeBackApi homeBackApi = (HomeBackApi) ARouter.getInstance().build(RouterApi.HOMEONCLICKIMPL).navigation();
//                    homeBackApi.onEnvType(doctorDetailInfo.getEnvType());
//                }
                    //存clientid
                    if (doctorDetailInfo.getClientId() != null) {
                        SharedPreferencesUtils.getInstance().save(UserInfo.clientId, doctorDetailInfo.getClientId());
                    }
                    if (notices.size() == 0) {
                        binding.noticeCardView.setVisibility(View.GONE);
                    } else if (notices.size() == 1) {
                        binding.noticeCardView.setVisibility(View.VISIBLE);
                        binding.notice.setNoticeList(notices);
                        binding.notice.pause();
                    } else {
                        binding.noticeCardView.setVisibility(View.VISIBLE);
                        binding.notice.setNoticeList(notices);
                    }
                    binding.homeBanner.setImages(banners);
                    binding.homeBanner.setImageLoader(new ImageLoader() {
                        @Override
                        public void displayImage(Context context, Object path, ImageView imageView) {
                            try {
                                Glide.with(context).load(path).transform(new CenterCrop()).into(imageView);
                            } catch (Throwable throwable) {

                            }
                        }
                    });
                    binding.homeBanner.start();
                    if (banners.size() == 0) {
                        binding.homebannerCardview.setVisibility(View.GONE);
                    }
                    if (doctorDetailInfo.isNewQrCode()) {
                        CommonAdapter.isPrescriptionSupport = true;
                        commonAdapter.notifyDataSetChanged();
                        SharedPreferencesUtils.getInstance().save("isShare", true);
                        SharedPreferencesUtils.getInstance().save("isNewQrCode", true);
                        binding.toDrugList.setText("查看药品清单，设置更多套餐");
                    } else {
                        CommonAdapter.isPrescriptionSupport = false;
                        commonAdapter.notifyDataSetChanged();
                        SharedPreferencesUtils.getInstance().save("isNewQrCode", false);
                        SharedPreferencesUtils.getInstance().save("isShare", false);
                        binding.toDrugList.setText("查看药品清单");
                    }
                    //是否显示多点执业认证状态(false置灰；true显示)
                    if (doctorDetailInfo.isNewPracticeStatus()) {
                        //显示状态
                        Glide.with(context).load(R.mipmap.certificate_off).transform(new CenterCrop()).into(binding.certificationIcon);
                        binding.certificationText.setTextColor(((Activity)context).getResources().getColor(R.color.color_333333));
                        binding.certificationText.setAlpha(1.0f);
                        binding.certificationTo.setTextColor(((Activity)context).getResources().getColor(R.color.newTheme));
                        binding.certificationTo.setAlpha(1.0f);
                        binding.toCertificate.setEnabled(true);
                    } else {
                        //置灰
                        Glide.with(context).load(R.mipmap.certificate_no).transform(new CenterCrop()).into(binding.certificationIcon);
                        binding.certificationText.setTextColor(((Activity)context).getResources().getColor(R.color.color_333333));
                        binding.certificationText.setAlpha(0.3f);
                        binding.certificationTo.setTextColor(((Activity)context).getResources().getColor(R.color.color_333333));
                        binding.certificationTo.setAlpha(0.3f);
                        binding.toCertificate.setEnabled(false);
                    }

                    if (doctorDetailInfo.isPrescriptionSupport()) {
                        binding.inquriySetting.setVisibility(View.GONE);
                    } else {
                        binding.inquriySetting.setVisibility(View.VISIBLE);
                    }
                    //我的问诊
                    updataMyRoonFunction(MY_INQURIY_ID,
                            doctorDetailInfo.getInquiryCount(),
                                    doctorDetailInfo.isNewHasCharges() &&   // 开通问诊
                                            (doctorDetailInfo.isWhiteSelfDoctor() || !doctorDetailInfo.isPrescriptionSupport()));  // 自营白名单 || 非自营
                    //我的处方
                    updataMyRoonFunction(MY_PRESCRIPTION_ID,
                            doctorDetailInfo.getPrescriptionCount(),
                                    doctorDetailInfo.isNewHasPrescribing());
                    //我的患教
                    updataMyRoonFunction(MY_PATIENTS_ID,
                            doctorDetailInfo.getTasksCount(),
                            doctorDetailInfo.isNewPatientEducation() &&  //开通我的患教
                                    (doctorDetailInfo.isWhiteSelfDoctor() || !doctorDetailInfo.isPrescriptionSupport()));// 自营白名单 || 非自营
                    //我的二维码
                    updataMyRoonFunction(MY_SCAN_ID,
                            0,
                            doctorDetailInfo.isNewQrCode() && !doctorDetailInfo.isPrescriptionSupport());
                    //患者随访
                    updataMyRoonFunction(MY_FOLLOWUP_ID,
                            doctorDetailInfo.getSelectCountConsulationSfRecord(),
                            doctorDetailInfo.isHomePageCharges() && //开通患者随访
                                    (doctorDetailInfo.isWhiteSelfDoctor() || !doctorDetailInfo.isPrescriptionSupport()));// 自营白名单 || 非自营
                        for (int i = 0; i < myRoomEntities.size(); i++) {
                            if (myRoomEntities.get(i).getId() == MY_LIVE_ID) {
                                myRoomEntities.remove(i);
                                continue;
                            }
                        }
                        if (doctorDetailInfo.getLiveVideo() != null && !doctorDetailInfo.isPrescriptionSupport() ) {
                            //我的直播
                            myRoomEntities.add(new MyRoonEntity(MY_LIVE_ID, doctorDetailInfo.getLiveVideo().getTitle(),
                                    doctorDetailInfo.getLiveVideo().getIcon_url(),
                                    doctorDetailInfo.getLiveVideo().getIcon_url(),
                                    doctorDetailInfo.getLiveVideo().getCount(),
                                    doctorDetailInfo.getLiveVideo().getIs_active() == 1 ? true : false));
                        }
                        binding.myRoom.setLayoutManager(new GridLayoutManager(context, 4));
                        binding.myRoom.setAdapter(myRoomAdapter);
                        for (int i = 0; i < myRoomEntities.size(); i++) {
                            if (myRoomEntities.get(i).getId() == MY_MEET_ID) {
                                myRoomEntities.remove(i);
                                continue;
                            }
                        }
                        if (doctorDetailInfo.getMeeting() != null && !doctorDetailInfo.isPrescriptionSupport() ) {
                            myRoomEntities.add(new MyRoonEntity(MY_MEET_ID, doctorDetailInfo.getMeeting().getTitle(),
                                    doctorDetailInfo.getMeeting().getIcon_url(),
                                    CommonUtils.imageTranslateUri(context, R.drawable.meeting_unselect),
                                    doctorDetailInfo.getMeeting().getCount(),
                                    doctorDetailInfo.getMeeting().getIs_active() == 1 ? true : false));
                        }
                        binding.myRoom.setLayoutManager(new GridLayoutManager(context, 4));
                        binding.myRoom.setAdapter(myRoomAdapter);

                    notifityLiveAdapter();
//                是否显示扫一扫，绑定代表
                    if (doctorDetailInfo.isAzShowScan() && ConfigApi.Open.isOpenScan) {
                        binding.toScan.setVisibility(View.VISIBLE);
                    } else {
                        binding.toScan.setVisibility(View.GONE);
                    }

                    //初审状态  0 未认证 1 认证中 2 认证成功 3 认证失败
                    if (doctorDetailInfo.getPreliminaryStatus() == 0) {
                        binding.authenticationTo.setText("去验证");
                        binding.authenticationTo.setTextColor(((Activity)context).getResources().getColor(R.color.newTheme));
                    } else if (doctorDetailInfo.getPreliminaryStatus() == 1) {
                        binding.authenticationTo.setText("验证中");
                        binding.authenticationTo.setTextColor(((Activity)context).getResources().getColor(R.color.newTheme));
                        binding.defaultNav.setVisibility(View.GONE);
                        binding.passNav.setVisibility(View.VISIBLE);
                        //服务患者数
                        binding.homeServerPatiens.setText(doctorDetailInfo.getPatientCount() == 0 ? "-" : doctorDetailInfo.getPatientCount() + "");
                        //患教数
                        binding.homePatientCount.setText(doctorDetailInfo.getConfimCount() == 0 ? "-" : doctorDetailInfo.getConfimCount() + "");
                        //问诊次数
                        binding.homeInqurityCount.setText(doctorDetailInfo.getChargesCount() == 0 ? "-" : doctorDetailInfo.getChargesCount() + "");
                        //医生姓名
                        binding.homeName.setText(doctorDetailInfo.getName());
                        //头像
                        Glide.with(context).load(doctorDetailInfo.getAvatar() == null ? R.mipmap.avatar_default : doctorDetailInfo.getAvatar()).transform(new CenterCrop(), new CircleCrop()).into(binding.homeAvatar);
                        //职称
                        binding.homeTitleName.setText(doctorDetailInfo.getTitleName());
                    } else if (doctorDetailInfo.getPreliminaryStatus() == 2) {
                        binding.authenticationTo.setText("验证通过");
                        binding.defaultNav.setVisibility(View.GONE);
                        binding.passNav.setVisibility(View.VISIBLE);
                        binding.authenticationTo.setTextColor(((Activity)context).getResources().getColor(R.color.color_0CBF89));
                        //服务患者数
                        binding.homeServerPatiens.setText(doctorDetailInfo.getPatientCount() == 0 ? "-" : doctorDetailInfo.getPatientCount() + "");
                        //患教数
                        binding.homePatientCount.setText(doctorDetailInfo.getConfimCount() == 0 ? "-" : doctorDetailInfo.getConfimCount() + "");
                        //问诊次数
                        binding.homeInqurityCount.setText(doctorDetailInfo.getChargesCount() == 0 ? "-" : doctorDetailInfo.getChargesCount() + "");
                        //医生姓名
                        binding.homeName.setText(doctorDetailInfo.getName());
                        //头像
                        Glide.with(context).load(doctorDetailInfo.getAvatar() == null ? R.mipmap.avatar_default : doctorDetailInfo.getAvatar()).transform(new CenterCrop(), new CircleCrop()).into(binding.homeAvatar);
                        //职称
                        binding.homeTitleName.setText(doctorDetailInfo.getTitleName());
                        //非AZ 显示已认证
//                    if (doctorDetailInfo.isAzUseNew() && (doctorDetailInfo.getPracticeStatus() == 2 || (doctorDetailInfo
                        if ((doctorDetailInfo.getPracticeStatus() == 2 || (doctorDetailInfo
                                .getPreliminaryStatus() == 2 && !doctorDetailInfo.isNewPracticeStatus())) ||
//                            (!doctorDetailInfo.isAzUseNew() && doctorDetailInfo.getPreliminaryStatus() == 2)) {
                                (doctorDetailInfo.getPreliminaryStatus() == 2)) {
                            binding.isPassCertification.setVisibility(View.VISIBLE);
                            binding.isPassCertification.setImageBitmap(BitmapFactory.decodeResource(((Activity)context).getResources(), R.mipmap.authentication_finish_0));
                            //显示实名验证
                            binding.authentication.setVisibility(View.GONE);
                        } else {
                            binding.isPassCertification.setVisibility(View.GONE);
                            //显示实名验证
                            binding.authentication.setVisibility(View.VISIBLE);
                        }
                    } else if (doctorDetailInfo.getPreliminaryStatus() == 3) {
                        binding.defaultNav.setVisibility(View.GONE);
                        binding.passNav.setVisibility(View.VISIBLE);
                        binding.authenticationTo.setText("验证不通过,去修改");
                        binding.authenticationTo.setTextColor(((Activity)context).getResources().getColor(R.color.color_FFA604));
                        //服务患者数
                        binding.homeServerPatiens.setText(doctorDetailInfo.getPatientCount() == 0 ? "-" : doctorDetailInfo.getPatientCount() + "");
                        //患教数
                        binding.homePatientCount.setText(doctorDetailInfo.getConfimCount() == 0 ? "-" : doctorDetailInfo.getConfimCount() + "");
                        //问诊次数
                        binding.homeInqurityCount.setText(doctorDetailInfo.getChargesCount() == 0 ? "-" : doctorDetailInfo.getChargesCount() + "");
                        //医生姓名
                        binding.homeName.setText(doctorDetailInfo.getName());
                        //头像
                        Glide.with(context).load(doctorDetailInfo.getAvatar() == null ? R.mipmap.avatar_default : doctorDetailInfo.getAvatar()).transform(new CenterCrop(), new CircleCrop()).into(binding.homeAvatar);
                        //职称
                        binding.homeTitleName.setText(doctorDetailInfo.getTitleName());
                    }

//                if (doctorDetailInfo.isAzUseNew()) {
                    binding.infoStatus.setVisibility(View.GONE);
                    //存取状态
                    localPreliminaryStatus = SharedPreferencesUtils.getInstance().getPop_Integer(UserInfo.preliminartStatus + doctorDetailInfo.getMobile(), 0);//本地初审状态
                    localPracticeStatus = SharedPreferencesUtils.getInstance().getPop_Integer(UserInfo.practiceStatus + doctorDetailInfo.getMobile(), 0);//本地执业资格认证状态
                    isFirstAzUseNew = SharedPreferencesUtils.getInstance().getPop_Boolean(UserInfo.isFirstAzUseNew + doctorDetailInfo.getMobile(), true);
                    //                平台审核状态 1待审核 2 待补充 3 审核通过
                    if (doctorDetailInfo.getPlatformAuditStatus() == 1 && !doctorDetailInfo.isNewQrCode()) {
                        //待审核
                        binding.infoStatus.setVisibility(View.VISIBLE);
                        binding.authentication.setVisibility(View.GONE);
                        Glide.with(context).load(R.mipmap.status_ing).into(binding.statusIcon);
                        binding.statusText.setText("正在审核中...");
                        binding.statusText.setTextColor(((Activity)context).getResources().getColor(R.color.newTheme));
                        return;
                    } else if (doctorDetailInfo.getPlatformAuditStatus() == 2) {
                        binding.infoStatus.setVisibility(View.VISIBLE);
                        binding.authentication.setVisibility(View.GONE);
                        Glide.with(context).load(R.mipmap.replenish).into(binding.statusIcon);
                        binding.statusText.setText("您的资料不完善，请补充证件");
                        binding.statusText.setTextColor(((Activity)context).getResources().getColor(R.color.color_FFA604));
                        //补充信息弹窗
                        popWindowListenter.supplementary(doctorDetailInfo);
                        return;
                    } else if (doctorDetailInfo.getPlatformAuditStatus() == 3) {
                        binding.infoStatus.setVisibility(View.GONE);
                    }
//                }

                    if (doctorDetailInfo.isNewPracticeStatus()) {
                        binding.authentication.setVisibility(View.VISIBLE);
                        //                多点执业认证状态 0 未认证 1 认证中 2 认证成功 3 认证失败
                        if (doctorDetailInfo.getPreliminaryStatus() != 2) {
                            return;
                        }

                        if (doctorDetailInfo.getPracticeStatus() == 0) {
                            popWindowListenter.toNewUserPopShow(doctorDetailInfo.getPracticeStatus(),"");
                            binding.certificationTo.setText("去认证");
                            binding.certificationTo.setTextColor(((Activity)context).getResources().getColor(R.color.newTheme));
                            return;
                        } else if (doctorDetailInfo.getPracticeStatus() == 1) {
                            binding.certificationTo.setText("认证中");
                            binding.certificationTo.setTextColor(((Activity)context).getResources().getColor(R.color.newTheme));
                            return;
                        } else if (doctorDetailInfo.getPracticeStatus() == 2) {
                            binding.certificationTo.setText("认证成功");
                            binding.certificationTo.setTextColor(((Activity)context).getResources().getColor(R.color.color_0CBF89));
                            binding.authentication.setVisibility(View.GONE);
                            binding.isPassCertification.setVisibility(View.VISIBLE);
                            if (doctorDetailInfo.isBzShow()) {
                                binding.isPassCertification.setImageBitmap(BitmapFactory.decodeResource(((Activity)context).getResources(), R.mipmap.authentication_finish_bz));
                            } else {
                                binding.isPassCertification.setImageBitmap(BitmapFactory.decodeResource(((Activity)context).getResources(), R.mipmap.authentication_finish));
                            }

                            if (doctorDetailInfo.getTumorHasCharging()) {
                                popWindowListenter.toNewUserPopShow(doctorDetailInfo.getPracticeStatus(),"");
                            }
                        } else if (doctorDetailInfo.getPracticeStatus() == 3) {

                            binding.certificationTo.setText("认证失败，去修改");
                            binding.certificationTo.setTextColor(((Activity)context).getResources().getColor(R.color.color_FFA604));
                            popWindowListenter.toNewUserPopShow(doctorDetailInfo.getPracticeStatus(),"");
                            return;
                        }


                    }


                } else {
                    LogUtils.e("数据获取失败 code = " + code);
                }
            }

            @Override
            public void onFailure(String s, int i) {

            }
        });
    }


    void getDoctorConfitm() {
        if (doctorDetailInfo == null){
            return;
        }
        getRepository().getDoctorConfirm(doctorDetailInfo.getDoctorPassportId() + "", new HttpCallBack<DoctorTirmEntity>() {
            @Override
            public void onSuccess(DoctorTirmEntity doctorTirmEntity, int i) {
                if (doctorTirmEntity.isResult()) {
                   popWindowListenter.information(doctorTirmEntity.getData());
                }
            }

            @Override
            public void onFailure(String s, int i) {

            }
        });
    }



    void notifityLiveAdapter() {
        if (ConfigApi.Open.DoctorStudio) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                myRoomEntities.removeIf(id -> id.getId() == MY_STUDIO_ID);
            }
            if (doctorDetailInfo !=null && doctorDetailInfo.isDoctorStudio()) {
                MyRoonEntity mystudio = new MyRoonEntity(MY_STUDIO_ID, "我的工作室", CommonUtils.imageTranslateUri(context, R.mipmap.my_studio),
                        CommonUtils.imageTranslateUri(context, R.mipmap.my_studio),
                        0,
                        true);
                if (!doctorDetailInfo.isHasDoctorWork()) {
                    mystudio.setUnReadCountDesc("待创建");
                }
                myRoomEntities.add(mystudio);
            } else {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                    myRoomEntities.removeIf(id -> id.getId() == MY_STUDIO_ID);
                }
            }

            if (doctorDetailInfo !=null && doctorDetailInfo.isPopUp()) {
                popWindowListenter.doctorSudio();
            }

        }

        for (int i = 0; i < myRoomEntities.size(); i++) {
            if (myRoomEntities.get(i).getId() == MY_STUDIO_ID) {
                myRoomEntities.get(i).setType(1);
            } else {
                myRoomEntities.get(i).setType(0);
            }
        }
        Collections.sort(myRoomEntities);
        binding.myRoom.setLayoutManager(new GridLayoutManager(context, 4));
        binding.myRoom.setAdapter(myRoomAdapter);
//        if (myRoomEntities.size() > 5) {
//
//        } else {
//            Collections.sort(myRoomEntities);
//            MyRoonEntity myRoonEntity = myRoomEntities.get(myRoomEntities.size() - 1);
//            if (myRoonEntity.getId() == MY_FOLLOWUP_ID) {
//                myRoomEntities.remove(myRoonEntity);
//                myRoomEntities.add(3, myRoonEntity);
//            }
//            binding.myRoom.setLayoutManager(new GridLayoutManager(context, 5));
//            binding.myRoom.setAdapter(myRoomAdapter);
//        }
        myRoomAdapter.notifyDataSetChanged();
    }




    View findViewById(int i){
      return ((Activity)context).findViewById(i);
    }

    /**
     * 设置我的诊室数据更改
     */
    void updataMyRoonFunction(int funcId, int unReadCount, boolean isHasFunction) {
        for (MyRoonEntity myroonEntity : myRoomEntities) {
            if (myroonEntity.getId() == funcId) {
                myroonEntity.setUnReadCount(unReadCount);
                myroonEntity.setHasFunction(isHasFunction);
            }
        }
        myRoomAdapter.notifyDataSetChanged();
    }


    public LiveTabBean.DataBean.MeetingBean getMeetingContentBean(){
        return meetingContentBean;
    }

    public void getLiveTabList(){
        getRepository().getLiveTabList(new HttpCallBack<LiveTabBean>() {
            @Override
            public void onSuccess(LiveTabBean liveTabBean, int code) {
                if (!"200".equals(liveTabBean.getCode()) || liveTabBean.getData() == null) return;
                if (ConfigApi.Open.isOpenMeeting) {
                    List<LiveTabBean.DataBean.MeetingBean> meeting1 = liveTabBean.getData().getMeeting();
                    if (meeting1 == null || meeting1.size() == 0) {
                        binding.meetingCardview.setVisibility(View.GONE);
                    } else {
                        binding.meetingCardview.setVisibility(View.VISIBLE);
                        binding.homeFragmentMeetingTitle.setText("我的会议");
                        meetingContentBean = meeting1.get(0);
                        if (meetingContentBean != null) {
                            if (meetingContentBean.getTitle() != null) {
                                binding.homeFragmentMeetingName.setText(meetingContentBean.getTitle());
                            }
                            if (meetingContentBean.getStarted_at() != null) {
                                binding.homeFragmentMeetingStartTime.setText(meetingContentBean.getStarted_date());
                            }
                            if (meetingContentBean.getStarted_date() != null) {
                                binding.homeFragmentMeetingStartDate.setText(meetingContentBean.getStarted_at());
                            }
                            if (meetingContentBean.getEnded_at() != null) {
                                binding.homeFragmentMeetingEndTime.setText(meetingContentBean.getEnded_date());
                            }
                            if (meetingContentBean.getEnded_date() != null) {
                                binding.homeFragmentMeetingEndDate.setText(meetingContentBean.getEnded_at());
                            }
                            if (meetingContentBean.getDiffTime() >= 0) {
                                binding.homeFragmentMeetingDuration.setText(meetingContentBean.getDiffTime() + "分钟");
                            }
                            if (meetingContentBean.getLive_status_text() != null) {
                                binding.homeFragmentMeetingStatus.setText(meetingContentBean.getLive_status_text());
                            }
                            if (meetingContentBean.getMeeting_url() != null) {
                                binding.homeFragmentMeetingUrl.setText("会议链接：" + meetingContentBean.getMeeting_url());
                            }
                            if (meetingContentBean.getScene_type() == 201) {
                                binding.homeFragmentMeetingUrl.setVisibility(View.INVISIBLE);
                                binding.homeFragmentMeetingCopy.setText("讲者协议");
                                if (meetingContentBean.getIs_need_sign() == 0 || meetingContentBean.getLive_status() == 99) {
                                    binding.homeFragmentMeetingCopy.setVisibility(View.INVISIBLE);
                                } else {
                                    binding.homeFragmentMeetingCopy.setVisibility(View.VISIBLE);
                                }
                            } else {
                                binding.homeFragmentMeetingUrl.setVisibility(View.INVISIBLE);
                                binding.homeFragmentMeetingCopy.setVisibility(View.INVISIBLE);
                            }
                            if (meetingContentBean.getLive_status() == 50) {
                                //带开始
                                binding.homeFragmentMeetingPoint.setBackground(((Activity)context).getResources().getDrawable(R.drawable.home_fragment_meeting_point));
                                binding.homeFragmentMeetingStatus.setTextColor(Color.parseColor("#FF831F"));
                                binding.homeFragmentMeetingLook.setTextColor(Color.parseColor("#3776F9"));
                                binding.homeFragmentMeetingLook.setText("立即查看");
                            } else if (meetingContentBean.getLive_status() == 51) {
                                //进行中
                                binding.homeFragmentMeetingPoint.setBackground(((Activity)context).getResources().getDrawable(R.drawable.home_fragment_meeting_point_green));
                                binding.homeFragmentMeetingStatus.setTextColor(Color.parseColor("#3776F9"));
                                binding.homeFragmentMeetingLook.setTextColor(Color.parseColor("#3776F9"));
                                binding.homeFragmentMeetingLook.setText("立即参会");
                            } else if (meetingContentBean.getLive_status() == 60) {
                                //结束
                                binding.homeFragmentMeetingPoint.setVisibility(View.GONE);
                                binding.homeFragmentMeetingStatus.setTextColor(Color.parseColor("#999999"));
                                binding.homeFragmentMeetingLook.setTextColor(Color.parseColor("#3776F9"));
                                binding.homeFragmentMeetingLook.setText("立即查看");
                            } else if (meetingContentBean.getLive_status() == 61) {
                                //取消
                                binding.homeFragmentMeetingPoint.setVisibility(View.GONE);
                                binding.homeFragmentMeetingStatus.setTextColor(Color.parseColor("#999999"));
                                binding.homeFragmentMeetingLook.setTextColor(Color.parseColor("#3776F9"));
                                binding.homeFragmentMeetingLook.setText("立即查看");
                            } else {
                                binding.homeFragmentMeetingPoint.setVisibility(View.GONE);
                                binding.homeFragmentMeetingStatus.setTextColor(Color.parseColor("#999999"));
                            }

                            if (meetingContentBean.getScene_type() == 202 || meetingContentBean.getScene_type() == 203) {
                                binding.homeFragmentMeetingCopy.setText("复制会议地址");
                                binding.homeFragmentMeetingLook.setText("查看详情");
                                binding.homeFragmentMeetingUrl.setVisibility(View.VISIBLE);
                                binding.homeFragmentMeetingCopy.setVisibility(View.VISIBLE);
                            }
                        } else {
                            binding.meetingCardview.setVisibility(View.GONE);
                        }
                    }
                } else {
                    binding.meetingCardview.setVisibility(View.GONE);
                }


                if (ConfigApi.Open.isOpenWeClass) {
                    if (liveTabBean.getData().getAlbum() != null) {
                        List<AlbumBean.Content> album = liveTabBean.getData().getAlbum();
                        if (album.size() == 0) {
//                            findViewById(R.id.we_class).setVisibility(View.GONE);
                            binding.liveClassroomView.setVisibility(View.GONE);

                        } else {
//                            findViewById(R.id.we_class).setVisibility(View.VISIBLE);
                            binding.liveClassroomView.setVisibility(View.VISIBLE);
                            binding.liveClassroomView.setData((LifecycleOwner) context, "微课堂", album);
//                            albumBeans.clear();
//                            albumBeans.addAll(album);
//                            weClassAdapter.notifyDataSetChanged();
                        }
                    }
                }


                if (liveTabBean.getData().getLive_category() != null) {
                    live_category = liveTabBean.getData().getLive_category();
                    if (liveTabBean.getData().getLive_category().size() == 0) {
                        binding.liveCardview.setVisibility(View.GONE);
                    } else {
                        binding.liveCardview.setVisibility(View.VISIBLE);
                        binding.liveTab.removeAllTabs();
                        for (LiveTabBean.DataBean.LiveCategoryBean s : liveTabBean.getData().getLive_category()) {
                            TabLayout.Tab tab = binding.liveTab.newTab();
                            tab.setText(s.getName());
                            binding.liveTab.addTab(tab);
                        }
                        for (int i = 0; i < liveTabBean.getData().getLive_category().size(); i++) {
                            LinearLayout linearLayout = (LinearLayout) binding.liveTab.getChildAt(i);
                            linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
                            linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.tab_item_r));
                        }
                        getLiveList(liveTabBean.getData().getLive_category().get(0).getId() + "");
                    }
                }
            }

            @Override
            public void onFailure(String s, int i) {

            }
        });
    }
    public void getLiveList(int p){
        if (live_category!=null){
            getLiveList(live_category.get(p).getId()+"");
        }
    }
    public void getLiveList(String s){
        getRepository().getLiveList(s,new HttpCallBack<LiveListEntity>() {
            @Override
            public void onSuccess(LiveListEntity liveListBean, int code) {
                if (liveListBean.getCode().equals("200") && liveListBean.getData() != null && liveListBean.getData().getList() != null) {
                    lives.clear();
                    ALog.i("HomeFragment -- get()", "" + liveListBean.getData().getList().size());
                    for (int i = 0; i < liveListBean.getData().getList().size(); i++) {
                        lives.add(liveListBean.getData().getList().get(i));
                    }
                    liveAdapter.notifyDataSetChanged();
                    if (liveListBean.getData().getList().size() > 0) {
                        binding.liveRecycler.setVisibility(View.VISIBLE);
                        findViewById(R.id.rv_live_none).setVisibility(View.GONE);
                    } else {
                        binding.liveRecycler.setVisibility(View.GONE);
                        findViewById(R.id.rv_live_none).setVisibility(View.VISIBLE);
                    }
                }else {
                    binding.liveRecycler.setVisibility(View.GONE);
                    findViewById(R.id.rv_live_none).setVisibility(View.VISIBLE);
                }
            }

            @Override
            public void onFailure(String failureMsg, int statusCode) {
                binding.liveRecycler.setVisibility(View.GONE);
                findViewById(R.id.rv_live_none).setVisibility(View.VISIBLE);
            }
        });
    }

    public void myRoomEntry(int p){
        int id = myRoomEntities.get(p).getId();
        ALog.i("onItemClick", "onItemClick: " + id);
        switch (id) {
            case MY_INQURIY_ID:
                //我的问诊点击
                ClickUtils.sendEvent(ClickApi.Home.Home_MyInquiry, context, "我的问诊点击");
                if (doctorDetailInfo == null){
                    return;
                }
                if (doctorDetailInfo.isPrescriptionSupport() && !doctorDetailInfo.isWhiteSelfDoctor()) {
                    return;
                }
                if (doctorDetailInfo.isNewHasCharges()) {
                    HomeUtils.push(context, ReactApi.IM_DOCTORBUNDLE, ReactApi.Message.MyPhysicianVisits);
                } else {
                    popWindowListenter.signPopShow();
                }
                break;
            case MY_PRESCRIPTION_ID:
                //我的处方点击
                ClickUtils.sendEvent(ClickApi.Home.Home_MyPrescription, context, "我的处方点击");
                if (doctorDetailInfo == null){
                    return;
                }
                if (doctorDetailInfo.isNewHasPrescribing()) {
                    Bundle bundle = new Bundle();
                    bundle.putBoolean("hasDoctorWork", doctorDetailInfo.isHasDoctorWork());
                    bundle.putBoolean("doctorStudio", doctorDetailInfo.isDoctorStudio());
                    HomeUtils.push(context, ReactApi.IM_DOCTORBUNDLE, ReactApi.Message.Prescriptions, bundle);
                } else {

                    popWindowListenter.signPopShow();
                }
                break;
            case MY_PATIENTS_ID:
                //我的患教点击
                ClickUtils.sendEvent(ClickApi.Home.Home_MyPatient, context, "我的患教点击");
                if (doctorDetailInfo == null){
                    return;
                }
                if (doctorDetailInfo.isPrescriptionSupport() && !doctorDetailInfo.isWhiteSelfDoctor()) {
                    return;
                }
                if (doctorDetailInfo.isNewPatientEducation()) {
                    HomeUtils.push(context, ReactApi.HOME_DOCTORBUNDLE, ReactApi.Home.MyTaskPage);
                } else {

                    popWindowListenter.signPopShow();
                }
                break;
            case MY_SCAN_ID:
                //出示二维码点击
                ClickUtils.sendEvent(ClickApi.Home.Home_MyQrcode, context, "出示二维码点击");
                if (doctorDetailInfo == null){
                    return;
                }
                if (doctorDetailInfo.isPrescriptionSupport()) {
                    return;
                }
                if (doctorDetailInfo.isNewQrCode()) {
                    //请求网络获取二维码
                    getScan();
                } else {

                    popWindowListenter.signPopShow();
                }
                break;
            case MY_FOLLOWUP_ID:
                //我的随访点击
                ClickUtils.sendEvent(ClickApi.Home.Home_MyFollow, context, "我的随访点击");
                if (doctorDetailInfo == null){
                    return;
                }
                if (doctorDetailInfo.isPrescriptionSupport() && !doctorDetailInfo.isWhiteSelfDoctor()) {
                    return;
                }
                if (doctorDetailInfo.isHomePageCharges()) {
                    HomeUtils.push(context, ReactApi.HOME_DOCTORBUNDLE, ReactApi.Home.FollowUp);
                } else {

                    popWindowListenter.signPopShow();
                }
                break;
            case MY_LIVE_ID:
                //我的直播点击
                ClickUtils.sendEvent(ClickApi.Home.Home_MyLive, context, "我的直播点击");
                HomeUtils.moveLive();
                break;
            case MY_MEET_ID:
                //我的会议点击
                ClickUtils.sendEvent(ClickApi.Home.Home_MyMeeting, context, "我的会议点击");
                if (myRoomEntities.get(p).isHasFunction()) {
                    HomeUtils.toJumeMeetList();
                }
                break;
            case MY_STUDIO_ID:
//                        StudioList
                //我的患教点击
//                        H5_SERVICE_DEBUG
                ClickUtils.sendEvent(ClickApi.Home.Home_MyStudio, context, "我的工作室点击");
                String url = HttpUtils.getH5Url() +
//                        String url = "http://192.168.5.141:8080/"+
                        "/index.html?t=" + System.currentTimeMillis() + "#" +
                        "/my-studio?tk=" +
                        DevicesUtils.getToken();
                ARouter.getInstance().build("/WebActivity/WebActivity")
                        .withString("title", "我的工作室")
                        .withString("url", url)
                        .withBoolean("ishtml", false)
                        .navigation();
                break;
        }
    }
    //实名认证-去认证
    public void toPreliminary() {
        ClickUtils.sendEvent(ClickApi.Home.Home_RealName, context, "实名验证点击");
        if (doctorDetailInfo == null){
            return;
        }
        if (!doctorDetailInfo.isPrescriptionSupport() && (doctorDetailInfo.getTitleName() != null && !doctorDetailInfo.getTitleName().isEmpty())) {// && doctorDetailInfo.getTitleName().equals("住院医师")
            return;
        }
        if (doctorDetailInfo.isStrongChannel()) {
            if (doctorDetailInfo.isAzUseNew()) {
                HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.AutonymApprovePage);
            } else {
                HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.AutonymApprovePage);
            }
        } else {
            HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.AutonymApprovePage);
        }
    }

    //多点执业认证-去认证
    public void toPractice() {
        ClickUtils.sendEvent(ClickApi.Home.Home_Practice, context, "多点执业认证点击");
        if (doctorDetailInfo == null){
            return;
        }
        if (doctorDetailInfo.isStrongChannel()) {
            if (doctorDetailInfo.isAzUseNew()) {
                HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.QualificationPass);
            } else {
                HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.QualificationPass);
            }
        } else {
            HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.QualificationPass);
        }
    }

    /**
     * 点击弹窗提示
     */
    public void signPopShow() {
        if (doctorDetailInfo == null){
            return;
        }
        if (doctorDetailInfo.getPreliminaryStatus() != 2) {
            popWindowListenter.realNameAuthentication();
        } else if (doctorDetailInfo.getPracticeStatus() != 2 && doctorDetailInfo.isNewPracticeStatus()) {
            //未多点
            popWindowListenter.multipoint();
        } else if (doctorDetailInfo.getWorkWebHospitalCode().equals("cd")) {
            popWindowListenter.auditPass();
        }
//        if (doctorDetailInfo.getPreliminaryStatus() != 2) {
//            //未实名验证
//            signCentent.setText("请先进行实名验证！");
//            signSure.setText("去实名验证");
//            signPop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
//            CommonUtils.setBackgroundAlpha(signPop, getActivity(), 0.3f);
//        }


    }

    /**
     * 获取二维码信息
     */
    void getScan() {
        LoadingUtils.getLoadingUtils(context).showLoading();
        getRepository().getScanInfo(new HttpCallBack<ScanEntity>() {
            @Override
            public void onSuccess(ScanEntity scanEntity, int code) {
                if (scanEntity.isResult()) {
                    ScanEntity.DataBean data = scanEntity.getData();
                    if (data != null) {
                        String s = null;
                        //判断是否显示时间
                        s = DataUtils.long2string(data.getTimeOut(), "yyyy-MM-dd");
                        popWindowListenter.showScan(data.getQrcodeUrl(),s);
                    }
                }
                LoadingUtils.getLoadingUtils(context).dismissLoading();
            }

            @Override
            public void onFailure(String failureMsg, int statusCode) {
                LoadingUtils.getLoadingUtils(context).dismissLoading();

            }
        });
    }

    public void updataIsNoProcess(int i) {
        if (doctorDetailInfo == null){
            return;
        }
        getRepository().getUpdataIsProcess(doctorDetailInfo.getDoctorPassportId(),i,new HttpCallBack<String>() {
            @Override
            public void onSuccess(String result, int code) {
                ALog.d("resultMsg", "resultMsg: " + result);
                popWindowListenter.infoHintDismiss();
            }

            @Override
            public void onFailure(String failureMsg, int statusCode) {

            }
        });
    }

    public HomeDoctorDetailEntity.DataBean getDoctorDetail(){
        return doctorDetailInfo;
    }

    public void toOpenInquiry() {
        if (doctorDetailInfo == null){
            return;
        }
        if (doctorDetailInfo.getTitle()) {
            HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.ChangeProfessional);
        } else {
            HomeUtils.push(context, ReactApi.IM_DOCTORBUNDLE, ReactApi.Message.Inquirysetup);
        }
    }

    public void liveDetail(int position) {
        ClickUtils.sendEvent(ClickApi.Home.Home_LiveDetail, context, "直播详情点击");
//                lives.get(position).get
        HomeUtils.toJumeLiveClient(lives.get(position).getId(), lives.get(position).getLive_client());
    }

    public void toAvator() {
        ClickUtils.sendEvent(ClickApi.Home.Home_Header, context, "头像点击");
        if (doctorDetailInfo == null){
            return;
        }
        if (doctorDetailInfo.getPracticeStatus() == 2) {
            HomeUtils.push(context, ReactApi.MY_DOCTORBUNDLE, ReactApi.Mine.BaseInfo);
        }
    }

    public void toBanner(int position) {
        ClickUtils.sendEvent(ClickApi.Home.Home_Banner, context, "banner点击");
        if (bannersUrl != null && bannersUrl.size() != 0) {
            boolean redirect = false;
            if (bannerList.get(position) instanceof HomeDoctorDetailEntity.DataBean.BannerListBean) {
                HomeDoctorDetailEntity.DataBean.BannerListBean bean = (HomeDoctorDetailEntity.DataBean.BannerListBean) bannerList.get(position);
                redirect = bean.getRedirect();
            } else if (bannerList.get(position) instanceof HomeDoctorDetailEntity.DataBean.ActivityResultListBean) {
                HomeDoctorDetailEntity.DataBean.ActivityResultListBean bean = (HomeDoctorDetailEntity.DataBean.ActivityResultListBean) bannerList.get(position);
                redirect = bean.isRedirect();
            }
            if (redirect) {
                String url = bannersUrl.get(position);
                if (!TextUtils.isEmpty(url)) {
                    //判断是否是scheme的URL
                    if (url.startsWith("com.doctor.scheme:url?")) {
                        //判断是否包含load=
                        if (url.contains("load=")) {
                            //截取赋值
                            String[] split = url.split("load=");
                            for (String s : split) {
                                if (s.startsWith("http")) {
                                    url = s;
                                    break;
                                }
                            }
                            if (!TextUtils.isEmpty(url) && url.startsWith("http")) {
                                ARouter.getInstance().build(RouterApi.WebActivity)
                                        .withString("title", "查看详情")
                                        .withBoolean("ishtml", false)
                                        .withString("url", url)
                                        .withBoolean("isShowLoading", true).navigation();
                            }
                        } else {
                            ALog.e(this.getClass().getSimpleName(), "解析Html 非HTTP支持URL");
                        }
                    }else if (url.startsWith("http")) {
                        ARouter.getInstance().build(RouterApi.WebActivity)
                                .withString("title", "查看详情")
                                .withBoolean("ishtml", false)
                                .withString("url", url)
                                .withBoolean("isShowLoading", true).navigation();
                        return;
                    } else if (url.startsWith("com.doctor.scheme://")) {
                        HomeUtils.toBannerClick(url);
                        return;
                    } else {
                        HomeUtils.toScheme(context,url);
                    }



                } else {
                    ALog.e(this.getClass().getSimpleName(), "解析Html URL为空");
                }
            }
        }
    }

    public void toAuthe() {
        if (doctorDetailInfo == null){
            return;
        }
        if (doctorDetailInfo.getPreliminaryStatus() != 2) {
            if (doctorDetailInfo.isAzUseNew()) {
                HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.AutonymApprovePage);
            } else {
                HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.AutonymApprovePage);
            }
        } else if (doctorDetailInfo.getPracticeStatus() != 2 && doctorDetailInfo.isNewPracticeStatus()) {
            if (doctorDetailInfo.isNewPracticeStatus()) {
                if (doctorDetailInfo.getPreliminaryStatus() != 2) {
                    signPopShow();
                } else {
                    if (doctorDetailInfo.isAzUseNew()) {
                        Bundle bundle = new Bundle();
                        bundle.putInt("notEdit", doctorDetailInfo.getPlatformAuditStatus());
                        bundle.putBoolean("azUseNew", doctorDetailInfo.isAzUseNew());
                        HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.QualificationPass, bundle);
                    } else {
                        Bundle bundle = new Bundle();
                        bundle.putInt("notEdit", doctorDetailInfo.getPlatformAuditStatus());
                        bundle.putBoolean("azUseNew", doctorDetailInfo.isAzUseNew());
                        HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.QualificationPass, bundle);
                    }
                }
            }
        } else if (doctorDetailInfo.getWorkWebHospitalCode().equals("cd")) {

        }
        popWindowListenter.signPopdismiss();
    }

    public void toNewUserBt() {
        if (doctorDetailInfo == null){
            return;
        }
        if (doctorDetailInfo.getPlatformAuditStatus() == 2) {
            //去补充
            Bundle bundle = new Bundle();
            bundle.putInt("notEdit", doctorDetailInfo.getPlatformAuditStatus());
            HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.UploadInfo, bundle);
        } else if (doctorDetailInfo.getPracticeStatus() == 3) {
            //去修改
            Bundle bundle = new Bundle();
            bundle.putInt("notEdit", doctorDetailInfo.getPlatformAuditStatus());
            bundle.putBoolean("azUseNew", true);
//                    bundle.putBoolean("azUseNew", doctorDetailInfo.isAzUseNew());
            HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.QualificationPass, bundle);
        } else if (doctorDetailInfo.getPracticeStatus() == 2) {
            //开启在线问诊
            HomeUtils.push(context, ReactApi.IM_DOCTORBUNDLE, ReactApi.Message.Inquirysetup);
        }
        popWindowListenter.newUserPopDismiss();
    }

    public void supplement() {
        if (doctorDetailInfo == null){
            return;
        }
        if (doctorDetailInfo.getPlatformAuditStatus() != 2) {
            return;
        }
        Bundle bundle = new Bundle();
        bundle.putInt("notEdit", doctorDetailInfo.getPlatformAuditStatus());
        HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.UploadInfo, bundle);
    }

    public void toScrollChange(float scrollY) {
        if (doctorDetailInfo != null && doctorDetailInfo.isBzShow()) {
            float alpha = scrollY / topScrollYFloat;
            binding.homeTitleTop.setAlpha(alpha > 1.0 ? 1.0f : alpha);
        } else {
            binding.homeTitleTop.setAlpha(1.0f);
        }
    }

    public void toNoticeDetail(int position) {
        ARouter.getInstance().build(RouterApi.WebActivity)
                .withString("title", noticeListBeans.get(position).getTitle())
                .withString("url", noticeListBeans.get(position).getContent())
                .withBoolean("ishtml", true)
                .withBoolean("isShowLoading", true)
                .navigation();
    }

    public void toGuideDetail(int position){
        LoadingUtils.getLoadingUtils(context).showLoading();
        getRepository().getDoctorGuideDetail(doctorGuides.get(position).getDocumentNo(),new HttpCallBack<ProtocalEntity>() {
            @Override
            public void onSuccess(ProtocalEntity protocalEntity, int code) {
                if (protocalEntity.isResult() && protocalEntity.getData() != null) {
                    String url = protocalEntity.getData().getContent();
                    if (!TextUtils.isEmpty(protocalEntity.getData().getVideoPath())) {
                        url = "<video src=\"" + protocalEntity.getData().getVideoPath() + "\" controls=\"controls\" autoplay=\"autoplay\"  style=\"width: 100%\" >\n" +
                                "your browser does not support the video tag\n" +
                                "</video>" + url;
                    }
                    ARouter.getInstance().build(RouterApi.WebActivity)
                            .withString("title", protocalEntity.getData().getTitle())
                            .withString("url", url)
                            .withBoolean("ishtml", true)
                            .withBoolean("isShowLoading", true)
                            .navigation();
                } else if (protocalEntity.isResult() && protocalEntity.getData() == null) {
                    ARouter.getInstance().build(RouterApi.WebActivity)
                            .withString("title", doctorGuides.get(position).getTitle())
                            .withString("url", doctorGuides.get(position).getContent())
                            .withBoolean("ishtml", true)
                            .withBoolean("isShowLoading", true)
                            .navigation();
                }
                LoadingUtils.getLoadingUtils(context).dismissLoading();

            }

            @Override
            public void onFailure(String failureMsg, int statusCode) {
                LoadingUtils.getLoadingUtils(context).dismissLoading();
            }
        });
    }

    public void toShare(int position) {
            ClickUtils.sendEvent(ClickApi.Home.Home_DrugsShare, context, "药品分享点击");
        if (doctorDetailInfo == null){
            return;
        }
            getRepository().getDrugShare(commonEntities.get(position),doctorDetailInfo.getDoctorPassportId(),doctorDetailInfo.getName(),new HttpCallBack<DrugShareEntity>() {

                @Override
                public void onSuccess(DrugShareEntity drugShareEntity, int i) {
                    if (drugShareEntity.isResult()) {
                        popWindowListenter.showDrugShare(drugShareEntity.getData());
                    }
                }

                @Override
                public void onFailure(String s, int i) {

                }
            });

    }

    public void toDrugDetail(int position) {
        if (doctorDetailInfo == null){
            return;
        }
        Bundle bundle = new Bundle();
        bundle.putLong("doctorId", doctorDetailInfo.getDoctorPassportId());
        bundle.putLong("packetId", commonEntities.get(position).getPacketId());
        bundle.putBoolean("isShare", doctorDetailInfo.isNewQrCode());
        HomeUtils.push(context, ReactApi.IM_DOCTORBUNDLE, ReactApi.Message.DrugDetail, bundle);
    }

    public void toShareFriends(RelativeLayout shareImg1) {
        if (doctorDetailInfo == null){
            return;
        }
        Bitmap shareImage = BitmapUtils.loadBitmapFromView(shareImg1);
        HomeUtils.shareWxImg(shareImage, doctorDetailInfo.getYwqOpenId());
    }

    public void toRZ() {
        if (doctorDetailInfo == null){
            return;
        }
        if (doctorDetailInfo.isNewPracticeStatus()) {
            if (doctorDetailInfo.getPreliminaryStatus() != 2) {
                signPopShow();
            } else {
                Bundle bundle = new Bundle();
                bundle.putInt("notEdit", doctorDetailInfo.getPlatformAuditStatus());
                bundle.putBoolean("azUseNew", true);
                HomeUtils.push(context, ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.QualificationPass, bundle);
   }
        }
    }

    public void toInquirySetting() {
        if (doctorDetailInfo == null){
            return;
        }
        if (doctorDetailInfo.getTumorHasCharging()) {
            HomeUtils.push(context, ReactApi.IM_DOCTORBUNDLE, ReactApi.Message.Inquirysetup);
        } else {
            signPopShow();
        }
    }

    public void toDrugMore() {
        if (doctorDetailInfo == null){
            return;
        }
        Bundle bundle = new Bundle();
        bundle.putLong("id", doctorDetailInfo.getDoctorPassportId());
        bundle.putBoolean("isShare", doctorDetailInfo.isNewQrCode());
        HomeUtils.push(context, ReactApi.IM_DOCTORBUNDLE, ReactApi.Message.DrugList, bundle);
    }

    public void saveImage(RelativeLayout shareImg1) {

        if (CommonUtils.checkPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) && CommonUtils.checkPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) {
            // 把一个View转换成图片
//                    if (drugShareEntity == null){
//                        return;
//                    }
//                    BitmapUtils.saveBitmap(BitmapUtils.GetImageInputStream(drugShareEntity.getData()),doctorDetailInfo.getName()+"-"+System.currentTimeMillis());
            if (doctorDetailInfo == null){
                return;
            }
            Bitmap shareImage = BitmapUtils.loadBitmapFromView(shareImg1);
            MediaStore.Images.Media.insertImage(context.getContentResolver(), shareImage, doctorDetailInfo.getName() + "-" + System.currentTimeMillis(), "");
            Toast.makeText(context, "保存成功", Toast.LENGTH_SHORT).show();
        } else {
            CommonUtils.getModuleCommonUtils().setRequestPermission((Activity) context, new String[]{
                    Manifest.permission.WRITE_EXTERNAL_STORAGE,
                    Manifest.permission.READ_EXTERNAL_STORAGE,
            }, 10001);
        }
    }
}
